<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head lang="en">
    <meta charset="UTF-8">
    <title>我的订单 - 达内学子商城</title>
    <link href="/user/css/my.order.css" rel="stylesheet" />
    <link href="/user/css/header.css" rel="stylesheet" />
    <link href="/user/css/footer.css" rel="stylesheet" />
    <link href="/user/css/set.css" rel="stylesheet" />
    <link href="/commons/css/bootstrap.css" rel="stylesheet" />
</head>
<body>
<!--顶部导航栏--> <!--注意引入的路径-->
<div th:replace="~{user/commons/commons::header}"></div>
    <!-- 主导航-->

    <!-- 主导航-->
    <nav id="nav1">
        <!-- 我的订单导航栏-->
        <div id="nav_order" class="lf">
            <ul>
                <li></li>
            </ul>
        </div>
    </nav>
</div>
<!--我的订单内容区域 #container-->
<div id="container" class="clearfix">
    <!-- 左边栏-->
    <div id="leftsidebar_box" class="lf">
        <div class="line"></div>
        <dl class="my_order">
            <dt onClick="changeImage()">帐号管理<img src="/user/img/myOrder/myOrder1.png"></dt>
            <dd class="first_dd"><a href="/password-change.html">修改密码</a></dd>
            <dd><a href="address-add.html">添加地址</a></dd>
        </dl>

    </div>
    <!-- 右边栏-->
    <div class="rightsidebar_box rt" >
        <div class="order_empty">
         <div id="cover" class="rt">
      <form name="form1" id="fm-changep" method="post" action="">
            <div class="txt">
                <p>修改密码
                    <span>
                        <a href="/user/page/index">继续购物</a>
                    </span>
                </p>

                <div th:if="${session.code!=null}">
                    <div class="text">
                        <input type="password" autocomplete="off" placeholder="请输入新密码" name="npwd" id="npwd" required minlength="6" maxlength="15">
                    </div>
                    <div class="text">
                        <input type="password" autocomplete="off" placeholder="请确认新密码" name="cpwd" id="cpwd" required minlength="6" maxlength="15">
                        <div id="pwdValidate"></div>
                    </div>
                    <div class="text">
                        <input class="button_login" type="button" value="提交" id="bt-changep" />
                        <div id="changeFail"></div>
                    </div>
                </div>
                <div th:if="${session.code==null}">
                    <div class="text">
                        <a href="forget-password.html"><h3 style="margin: 30px" class="btn btn-warning">请先点击这里验证邮箱</h3></a>
                    </div>

                </div>
            </div>
        </form>
        </div>
        </div>
    </div>
</div>
<!-- 品质保障，私人定制等-->
<div id="foot_box">
    <div class="icon1 lf">
        <img src="/user/img/footer/icon1.png" alt=""/>
        <h3>品质保障</h3>
    </div>
    <div class="icon2 lf">
        <img src="/user/img/footer/icon2.png" alt=""/>
        <h3>私人定制</h3>
    </div>
    <div class="icon3 lf">
        <img src="/user/img/footer/icon3.png" alt=""/>
        <h3>学员特供</h3>
    </div>
    <div class="icon4 lf">
        <img src="/user/img/footer/icon4.png" alt=""/>
        <h3>专属特权</h3>
    </div>
</div>
<!-- 页面底部-->
<div th:replace="~{user/commons/commons::foot}"></div>
</body>
<script src="/user/js/jquery-3.1.1.min.js"></script>
<script src="/user/js/index.js"></script>
<script src="/user/js/jquery.page.js"></script>
<script src="/user/js/order.js"></script>
<script type="text/javascript">

	//验证新密码和确认密码是否一致
	$("#cpwd").blur(function(){
		var npwd = $("#npwd").val();
		var cpwd = $("#cpwd").val();
		if(npwd==cpwd){
			$("#pwdValidate").text("");
        }else{
            $("#pwdValidate").text("新密码不一致");
            $("#pwdValidate").css("color","red");
	        return false;
		}
	});
	$('#bt-changep').click(function(){
        //读取用户的输入——表单序列化
        //var inputData = $('#fm-changep').serialize();
        var npwd = $("#npwd").val();
        var cpwd = $("#cpwd").val();
        if(npwd==cpwd){
            $("#pwdValidate").text("");
        }else{
            alert("两次密码不一致");
            return false;
        }
        //异步提交请求
        $.ajax({
        	async: true,
            type: 'POST',
            url: '/user/page/changePassword',
            data: 'cpwd='+cpwd,
            success: function(msg){
                if(msg=='ok'){  //修改成功
                    window.location.href =  "/userlogin.html";
                }else{ //修改失败
                    $('#changeFail').html('修改失败！');
                    $("#changeFail").css("color","red");
                }
            }
        });
    });
</script>
</html>
